const webpack = require('webpack');
const path = require('path');
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    devServer:{
        historyApiFallback:true,
        hot:true,
        inline:true,
        progress:true,
        contentBase:'./app',
        port:8080

    },
    entry:[
        'webpack/hot/dev-server',
        'webpack-dev-server/client?http://localhost:8080',
        path.resolve(__dirname,'app/main.jsx')
    ],
    output:{
        path:path.resolve(__dirname,'build'),
        publicPath:'/',
        filename:'./bundle.js'
    },
    devtool:'source-map',
    module:{
        loaders:[
            {test:/\.css$/,include:path.resolve(__dirname,'app'),loader:ExtractTextPlugin.extract('style','css')},
            {test:/\.js[x]?$/,include:path.resolve(__dirname,'app'),exculde:'/node_modules/',loader:'babel-loader',query:{
                presets:['es2015','react']
            }}
        ]
    },
    resolve:{
        extension:['','.js','.jsx']
    },
    plugins:[
        new webpack.HotModuleReplacementPlugin(),
        new ExtractTextPlugin("styles.css"),
        new HtmlWebpackPlugin({ filename: 'index.html'}),
        new OpenBrowserPlugin({url:'http://localhost:8080'})
    ]
}